package tw.com.book;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import tw.com.book.componet.TableContent;
import tw.com.book.componet.VoUtils;
import android.app.Application;

import com.parse.Parse;
import com.parse.ParseObject;
import com.parse.ParseQueryAdapter;

public class BookApplication extends Application {

	private Map<String, TableContent> tables = new HashMap<String, TableContent>();//table:sigm

	@Override
	public void onCreate() {

		Parse.initialize(this, "21Py6wsdruku0PmI0jd5qIHXcyrRad2mf2IrXuQ4", "j2961ZjkjGsdCHI5mtxkwESeatBWXnhJ1RVWvtAU");
		this.bindTable();

	}

	public TableContent getTable(String table) {
		return this.tables.get(table);
	}

	/**
	 * 綁定環境db變數
	 * 
	 */
	private void bindTable() {
		List<TableContent> tableContents = VoUtils.loadAllDomain(getApplicationContext());

		for (TableContent table : tableContents) {
			this.tables.put(table.getTable(), table);
		}
	}

}
